package org.example.two.sort;

import org.example.two.Example;

/**
 * 插入排序
 */
public class Insertion extends Example {
    @Override
    public void sort(Comparable[] a) {
        for (int i = 0; i < a.length; i++) {
            for (int j = i; j>0 && les(a[j],a[j-1]); j--) {
                exch(a,j,j-1);
            }
        }
    }
}
